package com.example.springsecurity.common.task;

import com.example.springsecurity.mapper.SystemOperationLogMapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @Description：系统操作日志定时任务
 * @Author： fengcheng
 * @Date： 2025/1/17 11:34
 */
@Slf4j
@Component
public class SystemOperationLogTask {

    @Resource
    private SystemOperationLogMapper systemOperationLogMapper;

    /**
     * @Description：每天凌晨2点执行删除7前天的系统操作日志数据任务
     * @Author：fengcheng
     * @Date：2025/1/17 11:36
     * @Return：void
     */
    @Scheduled(cron = "0 0 2 * * ?")
    public void delete7DaysAgoData() {
        int rowsDeleted = systemOperationLogMapper.delete7DaysAgoData();
        log.info("每天凌晨2点执行删除7前天的系统操作日志数据任务，执行完成，删除条数：{}", rowsDeleted);
    }
}
